<template>
  <div class="page-account page-frame">
    <div class="page-frame-body">
      <div class="acc-header">
        <div class="acc-user">
          <div class="a-u-img">
            <img v-bind:src="avator" />
          </div>
          <div class="a-u-name">小明</div>
          <div class="a-u-tel">15000010120</div>
        </div>
        <div class="acc-score">
          <p>
            <span class="s-s">{{(deposit/100).toFixed(2)}}</span>
            <span class="s-num"> 账户余额(元)：</span>
            <span @click="GoRecharge" class="btn-recharge">充值</span>
          </p>
        </div>
      </div>

      <menu class="acc-list">
        <ul>
          <li><div @click="GoEmployList" class="l-item l-item-1">企业用户</div></li>
          <li><div  @click="GoRechargeRecord" class="l-item l-item-2">充值记录</div></li>
          <li><div  @click="GoChargeRecord" class="l-item l-item-2">充电记录</div></li>
          <li><div @click="GoMyFav" class="l-item l-item-3">收藏站点</div></li>
          <li><div @click="Jump('/business')" class="l-item l-item-4">招商代理</div></li>
          <li><div @click="Jump('/help')" class="l-item l-item-5">使用帮助</div></li>
          <li><div @click="Jump('/aboutus')" class="l-item l-item-6">关于我们</div></li>
          <li><div @click="Jump('/suggestion')" class="l-item l-item-7">投诉建议</div></li>
        </ul>
      </menu>
    </div>
    <nav-toolbars data="3"></nav-toolbars>
  </div>
</template>

<script>
import NavToolbars from "@/components/navigation.vue";
export default {
  name: "HelloWorld",
  data() {
    return {
      id: 0,
      name: "",
      avator: require("@/public/imgs/avator.jpg"),
      sex: "",
      mobile: "",
      deposit: 0
    };
  },
  components: {
    NavToolbars
  },
  mounted() {
    console.log(1);
    this.initData();
  },
  methods: {
    initData() {
      var self = this;
      var req = this.Axios.get(this.Interface.host, {
        params: self.GetQuery()
      });
      // 请求数据
      req.then(res => {
        var data = res.data.data.me;
        if (data != null) {
          this.id = data.id;
          this.name = data.name;
          this.sex = data.sex;
          this.mobile = data.mobile;
          this.deposit = data.deposit;
        }
      });
      // 请求接口失败
      req.catch(res => {
        this.Toast("服务器开小差了~");
      });
    },
    GetQuery() {
      return {
        query: `{
                me {
                  id
                  name
                  sex
                  phone
                  deposit
                }
              }`
      };
    },
    GoRecharge() {
      var host = window.location.host;
      var url = encodeURI("https://ysc.mmcai.cn/web/h5/index.html#/payresult");
      this.$router.push({
        path: "recharge",
        query: { url: url }
      });
    },
    Jump(url) {
      this.$router.push({
        path: url
      });
    },
    GoEmployList() {
      this.$router.push("employList");
    },
    GoChargeRecord() {
      this.$router.push("chargeRecord");
    },
    GoRechargeRecord() {
      this.$router.push("rechargeRecord");
    },
    GoWallet() {},
    GoMyFav() {
      // 收藏夹列表
      this.$router.push("myfavority");
    }
  }
};
</script>

<style lang="less" scoped>
.acc-header {
  width: 100%;
  height: 340px;
  box-sizing: border-box;
  overflow: hidden;
  background: #f3f3f3;
  .acc-user {
    height: 190px;
    box-sizing: border-box;
    padding: 35px 45px 35px 220px;
    .a-u-img {
      position: absolute;
      left: 45px;
      top: 35px;
      width: 128px;
      height: 128px;
      img {
        display: block;
        width: 100%;
        height: 100%;
      }
    }
    .a-u-name {
      font-size: 35px;
      color: #333;
      margin-bottom: 20px;
      padding: 20px 0 0 0;
    }
    .a-u-tel {
      font-size: 26px;
      color: #999;
    }
  }
}

.acc-score {
  width: 100%;
  height: 150px;
  background: -webkit-linear-gradient(top, #39aaec, #2992ed);
  box-sizing: border-box;
  color: #fff;
  display: -webkit-box;
  -webkit-box-align: center;
  p {
    height: 65px;
    line-height: 65px;
    font-size: 34px;
    box-sizing: border-box;
    padding: 0 45px;
    overflow: hidden;
    width: 100%;
    span {
      display: inline-block;
    }
    .s-s {
      font-size: 70px;
    }
    .s-num {
      float: left;
      margin-right: 40px;
    }

    .btn-recharge {
      float: right;
      width: 130px;
      height: 60px;
      text-align: center;
      line-height: 68px;
      border-radius: 30px;
      font-size: 28px;
      margin: 0 auto;
      color: #fff;
      border: 2px solid #fff;
    }
  }
}

.acc-list {
  box-sizing: border-box;
  overflow: hidden;
  padding: 0;
  margin: 0;
  width: 100%;
  li {
    float: left;
    width: 33.333%;
    height: 200px;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    box-sizing: border-box;
    font-size: 26px;
    display: -webkit-box;
    -webkit-box-align: center;
    -webkit-box-pack: center;
    &:nth-child(3n) {
      border-right: none;
    }
    .l-item {
      display: block;
      width: 100%;
      height: 200px;
      box-sizing: border-box;
      text-align: center;
      padding: 150px 0 0 0;
    }
  }
}

.l-item-1 {
  background: url("../public/imgs/i-1.svg") center no-repeat;
  background-size: 750px;
}
.l-item-2 {
  background: url("../public/imgs/i-2.svg") center no-repeat;
  background-size: 750px;
}
.l-item-3 {
  background: url("../public/imgs/i-3.svg") center no-repeat;
  background-size: 750px;
}
.l-item-4 {
  background: url("../public/imgs/i-4.svg") center no-repeat;
  background-size: 750px;
}
.l-item-5 {
  background: url("../public/imgs/i-5.svg") center no-repeat;
  background-size: 750px;
}
.l-item-6 {
  background: url("../public/imgs/i-6.svg") center no-repeat;
  background-size: 750px;
}
.l-item-7 {
  background: url("../public/imgs/i-7.svg") center no-repeat;
  background-size: 750px;
}
</style>



